package com.tengju.support.domain.model.img;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;

@AllArgsConstructor
public enum PicType {

    LINE(1,"折线图"),
    BAR(2,"柱状图"),
    PIE(3,"饼图"),
    ;

    private Integer val;
    private String desc;

    @JsonValue
    public Integer getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    @JsonCreator
    public static PicType fromVal(Integer val) {
        for (PicType type : values()) {
            if (type.val.equals(val)) {
                return type;
            }
        }
        return null;
    }

}
